﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace Observer
{
    [TestFixture]
    public class ChineseFoodFixture
    {
        private bool eventFired;
        private ChineseFood food;

        [SetUp]
        public void Init()
        {
            food = new ChineseFood("Chicken");
            eventFired = false;
        }

        [Test]
        public void Attach()
        {
            food.ServeEvent += new ChineseFood.ServeHandler(OnServe);
            food.Serve();

            Assertion.AssertEquals(true, eventFired);
        }

        [Test]
        public void DoNotAttach()
        {
            food.Serve();
            Assertion.AssertEquals(false, eventFired);
        }

        private void OnServe(object subject)
        {
            eventFired = true;
        }
    }
}